﻿@using DirigoEdge.Utils
@{

    int count = 0;
    foreach (var blog in Model)
    {
        count++;
        string evenOddClass = count % 2 == 0 ? "even" : "odd";
        
        // First blog should be full-width, the rest are stacked
        string columns = (count == 1 && !Request.IsAjaxRequest()) ? "twelve columns" : "six columns";
        
        <article class="blogArticle @evenOddClass @columns" data-id="@blog.BlogId">

            @{
                var blogAuthor = "Anonymous";
                var blogAuthorUrl = "#";
                if (blog.Author != "")
                {
                    blogAuthor = blog.Author;
                    blogAuthorUrl = blog.BlogAuthorUrl + "/" ?? "#";
                }
                if (!String.IsNullOrEmpty(blog.ImageUrl))
                {
                    <a href="/blog/@blog.PermaLink/">
                        <img src="@blog.ImageUrl" alt="@blog.Title" />
                    </a>
                }
         
            }
            <h4><a href="/blog/@blog.PermaLink/">@blog.Title</a></h4>
            
            @{
                string inCategoryLanguage = String.IsNullOrEmpty(blog.MainCategory) ? "" : " in <a class='categoryLink' href='/blog/categories/" + ContentUtils.GetFormattedUrl(blog.MainCategory) + "'/>" + blog.MainCategory + "</a>";
            }
            <p class="byLine">Written by <a href="@blogAuthorUrl">@blogAuthor</a>@Html.Raw(inCategoryLanguage)</p>
            <p class="dateLine">@blog.Date.ToLongDateString()</p>
            
            <div class="row">
                <div class="userBlogContent twelve columns">
                    @Html.Raw(blog.ShortDesc)
                </div>
            </div>
        </article>
    }
}